﻿<UserControl
    x:Class="SuperQuiz.View.QuizAnswerControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SuperQuiz.View"
    xmlns:common="using:SuperQuiz.Common"
    xmlns:utils="using:SuperQuiz.Utils"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400"
    x:Name="quizAnswerControl">
    <UserControl.Resources>
        <utils:StringIsNullOrEmptyToVisibilityConverter x:Key="StringIsNullOrEmptyToVisibilityConverter"/>
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <utils:ValueConverterGroup x:Key="InvertedBooleanToVisibilityConverter">
            <common:BooleanNegationConverter />
            <common:BooleanToVisibilityConverter />
        </utils:ValueConverterGroup>
    </UserControl.Resources>

    <Grid>
        <StackPanel Margin="8,0,8,8" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=quizAnswerControl}">
            <TextBlock Text="{Binding Name}" TextWrapping="Wrap" TextTrimming="WordEllipsis" MaxHeight="100" Style="{StaticResource TitleTextStyle}" Foreground="White"/>
            <TextBlock Text="{Binding Description}" TextWrapping="Wrap" TextTrimming="WordEllipsis" MaxHeight="100" Style="{StaticResource LargeTextBlockTextStyle}" Foreground="White"/>
            <Image Source="{Binding ImageUri, Converter={StaticResource StringToImageConverter}}" Visibility="{Binding ImageUri, Converter={StaticResource StringIsNullOrEmptyToVisibilityConverter}}" Stretch="Uniform" Height="200"  Margin="8,8,8,8" HorizontalAlignment="Left"/>
            <local:QuizLinksListControl DataContext="{Binding Links}" Height="Auto" VerticalAlignment="Top" />
        </StackPanel>
        <Grid Margin="8,0,8,8" Visibility="{Binding IsSelected, Converter={StaticResource InvertedBooleanToVisibilityConverter}, ElementName=quizAnswerControl}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Image Source="{Binding ImageUri, Converter={StaticResource StringToImageConverter}}" Stretch="Uniform" Margin="0,0,8,0"  Visibility="{Binding ImageUri, Converter={StaticResource StringIsNullOrEmptyToVisibilityConverter}}" Width="48" />
            <TextBlock Grid.Column="1" Text="{Binding Name}" TextWrapping="Wrap" TextTrimming="WordEllipsis" MaxHeight="100" Style="{StaticResource TitleTextStyle}" />
        </Grid>
    </Grid>
</UserControl>
